﻿#region Using Statements
using System;
using System.Net;
#endregion

namespace DirectZZT.Server
{
    /// <summary>
    /// Stores the information about a connected client.
    /// </summary>
    public sealed class ClientInfo : IEquatable<string>
    {
        /// <summary>
        /// Gets the <see cref="IPEndPoint"/> instance of this client.
        /// </summary>
        public IPEndPoint EndPoint { get; private set; }
        /// <summary>
        /// Returns the name of this client.
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// Initializes a new instance of the ClientInfo class.
        /// </summary>
        /// <param name="endPoint"></param>
        /// <param name="name"></param>
        public ClientInfo(IPEndPoint endPoint, string name)
        {
            this.EndPoint = endPoint;
            this.Name = name;
        }

        #region IEquatable<string> Members

        /// <summary>
        /// Returns whether or not the string equals this instance.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(string other)
        {
            return string.Equals(this.Name, other, StringComparison.InvariantCulture);
        }

        #endregion
    }
}
